package com.me.chat.controller.bis;

import com.me.chat.util.FastDFSClientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @Author: qiu
 * @Date: 2021/4/21 14:05
 */
@RestController
@RequestMapping("/download")
public class DownloadController {

    @Autowired
    FastDFSClientUtil fastDFSClientUtil;

    /**
     * 原图下载接口
     * @param urlPath
     * @return
     */
    @PostMapping("/getUrlByte")
    public byte[] getUrlByte(String urlPath){
        byte[] bytes = null;
        try {
            bytes = fastDFSClientUtil.downloadFile(urlPath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return bytes;
    }
}
